<div class="main_bd">

    <div class="panel panel_overview">
        <div class="panel__hd">
            <h3 class="panel__title">发布团购</h3></div>
        <button class="panel__bd">

            <!--<div class="filter-box">-->
            <!--<a href="" class="btn btn_primary">新建群发</a>-->
            <!--</div>-->
            <form class="form" action="/group/save" enctype="multipart/form-data" method="post">
                <input type="hidden" name="goods_id" value="{$goods.id}">
                <div class="fieldset">
                    <h3 class="title">货品信息
                        <small class="small">(不可修改)</small>
                    </h3>
                    <div class="box">
                        <table class="info-list">
                            <tr>
                                <!--<td class="label">货品id</td>-->
                                <!--<td>{$goods.id}</td>-->
                                <td class="label">名称</td>
                                <td>{$goods.title}【{$goods.id}】</td>
                                <td class="label">缩略图</td>
                                <td><img width="100px" src="{$goods.thumb}"/></td>
                                <td class="label">发货地</td>
                                <td>{$goods.city.name}</td>
                            </tr>
                            <tr>
                                <td class="label">门店售价</td>
                                <td>￥{$goods.marketprice}</td>
                                <td class="label">平台售价</td>
                                <td class="red">￥{$goods.price}</td>
                                <td class="label">发布时间</td>
                                <td>{$goods.create_time}</td>
                            </tr>

                        </table>
                    </div>
                </div>

                <div class="fieldset">
                    <h3 class="title">团购起售价
                    </h3>

                    <div class="box">
                        <div class="form_group">
                            <label style="line-height: 32px;">团购起售价</label>
                            <input class="form-control len" type="text" name="price" max="{$goods.price}" />  <small class="small">(*要低于平台现售价格￥{$goods.price}元)</small>
                        </div>
                        <div class="form_group">
                            <label style="line-height: 32px;">每人限购数量</label>
                            <input class="form-control len" value="0" type="text" name="limit" min="0" />  <small class="small">(*不设置代表不限制)</small>
                        </div>

                    </div>
                </div>

                <div class="fieldset">
                    <h3 class="title">价格及库存
                        <small class="small">(所有规格价格及库存必填,拼团库存及价格只有拼团期间生效)</small>
                    </h3>
                    <div class="box">
                        <table class="info-list">
                            <tr>
                                <th width="100px">商品id</th>
                                <th>规格</th>
                                <th>正常售价</th>
                                <th>正常库存</th>
                                <th>拼团售价</th>
                                <th>拼团库存</th>
                            </tr>
                            {volist name="$goods.mall" id="mall" }
                            <tr>
                                <td>{$mall.id}</td>
                                <td>
                                    {volist name="mall.specs" id="spec" }
                                    <div class="info-line"><span class="em">{$spec.title}</span> :
                                        <span>{$spec.val}</span></div>
                                    {/volist}
                                </td>
                                <td>{$mall.price}</td>
                                <td>{$mall.stock}</td>

                                <td><input name="mall[{$mall.id}][price]" type="number" min="0" max="{$mall.price}" step="0.01"></td>
                                <td><input name="mall[{$mall.id}][stock]" type="number" min="1"></td>
                            </tr>
                            {/volist}
                        </table>
                    </div>
                </div>

                <div class="fieldset">

                    <h3 class="title">起止时间
                        <small class="small">(*在团购期内不可对产品进行编辑/下架等操作)</small>
                    </h3>
                    <div class="box">

                        <div class="form_group">
                            <label style="line-height: 32px;">开始时间</label>
                            <input class="form-control layer-date" style="width:360px;" required  name="totime"
                                   placeholder="YYYY-MM-DD hh:mm:ss"
                                   onclick="laydate({istime: true, format: 'YYYY-MM-DD hh:mm:ss'})">

                        </div>
                        <div class="form_group">
                            <label style="line-height: 32px;">结束时间</label>
                            <input class="form-control layer-date" style="width:360px;" required name="endtime"
                                   placeholder="YYYY-MM-DD hh:mm:ss"
                                   onclick="laydate({istime: true, format: 'YYYY-MM-DD hh:mm:ss'})">

                        </div>
                    </div>
                </div>
                <button class="btn btn_primary">发布</button>
            </form>


        </div>
    </div>
</div>
<script>

    function getStatus(status) {
        if (status == 3) return '已上架'
        if (status == 0) return '未上架'
        return '状态异常';//万一还有其他的呢
    }

    function taggleSatus(id, status) {
        var action = 'up';

        if (status == 0) {
            action = 'down'
        }
        $.post('/mall/' + action, {id: id}, function (res) {
            if (res.code == 1) {
                layer.msg('切换成功');
                grid.draw();

            }
        })
    }



</script>